Repository navigation
runtime, runtime/pprof: add Func.Entry and goroutine labels - #5646
Conversation
c2a7a18 to
b96d520
Compare
b96d520 to
a7c0657
Compare
davecheney
left a comment
There was a problem hiding this comment.
Thanks for working on this.
https://cs.opensource.google/go/go/+/refs/tags/go1.27.1:src/runtime/pprof/label.go;l=141
The upstream label support seems, at least superficially, to be propogated through context.Context so possibly we can just take the upstream version whole cloth. This would be a larger change, but i'm not convinved adding an inert label implementation wouldnt just add more complications down the line
|
Agreed, and done in
Checked by building a program against a patched TinyGo root and running the |
|
|
||
| // Entry returns the entry address of the function. Stubbed like the rest of | ||
| // runtime.Func on TinyGo; provided so callers that reference it (e.g. | ||
| // github.com/stretchr/testify/mock via FileLine(f.Entry())) compile. |
There was a problem hiding this comment.
I'd rather avoid mentioning unrelated 3rd party libs
runtime.Func.Entry is stubbed like the rest of runtime.Func. testify's mock package calls FileLine(f.Entry()). runtime/pprof gains the goroutine label API that grpc references. It is upstream's pre-1.24 implementation, because Go 1.24 moved the label type into internal/runtime/pprof/label, which TinyGo does not have. The label set lives in the context, so none of it needs the runtime. SetGoroutineLabels stays a no-op, since TinyGo's profiler is itself a stub and nothing would read the labels back.
bab208b to
56495f1
Compare
davecheney
left a comment
There was a problem hiding this comment.
LGTM. Thank you, this seems pretty self contained.
|
Thank you for the improvement @0pcom and to @davecheney and @b0ch3nski for review. Now merging. |
Fixes #5761.
Two source compatibility gaps, found while compiling larger Go programs under
TinyGo.
runtime.Func.Entry is stubbed like the rest of runtime.Func. testify's mock
package calls FileLine(f.Entry()).
runtime/pprof gains the goroutine label API that grpc references. It is
upstream's pre-1.24 implementation, because Go 1.24 moved the label type into
internal/runtime/pprof/label, which TinyGo does not have. The label set lives
in the context, so none of it needs the runtime. SetGoroutineLabels stays a
no-op, since TinyGo's profiler is itself a stub and nothing would read the
labels back.
Verified against host Go running the same program. Label lookup, ForLabels
ordering and early stop, child override with the parent left intact, Do
inheriting and not leaking, and the odd-argument panic all match. Also builds
for -target=wasm.